// TOWN SCRIPT
//    Town 12: Stone Circle

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

short i,j,choice;
short lead_char;

body;

beginstate INIT_STATE;
// This state called whenever this town is entered

 i = 0;
 while (i < 5) {
  if (char_ok(i)) {
   lead_char = i;
   i = 5;
  }
  else
   i = i + 1;
 }

set_crime_tolerance(1);
 
set_flag(4,15,1);
force_instant_terrain_redraw();

if (get_sdf(4,14) == 0) {
 set_flag(4,14,1);
 message_dialog("You discover a mysterious marvel of engineering. Several large stone pillars have been erected here in a circular pattern. Centuries, perhaps even millennia, of erosion has worn away at the spires.","It is really quite impressive. Unfortunately, there is no marking to tell you who erected this structure and for what purpose.");
}

break;

beginstate EXIT_STATE;

set_flag(4,15,0);

break;

beginstate START_STATE;

break;


beginstate 10;

if (get_terrain(16,16) == 270) {
 message_dialog("At the center of the stone circle is a slightly elevated platform that has worn, but still markable, decorations. It must have been quite a sight when it was new.","At the center of the platform is a glowing rune. It is a gold triangle with a circle at each point colored red, green, and blue.");
 block_entry(1);
}
if (get_terrain(16,16) == 268) {
 reset_dialog();
 add_dialog_str(0,"A teleporter floats above the pedestal. You have no idea at all where it will take you. Entering it will be a huge risk.",0);
 add_dialog_choice(0,"Enter the portal.");
 add_dialog_choice(1,"Stay away.");
 choice = run_dialog(1);
 if (choice == 1)
  set_state_continue(11);
 else
  block_entry(1);
}

break;


beginstate 11;

i = 0;
while (i < 6) {
 put_boom_on_char(i,2,0);
 i = i + 1;
}
force_instant_terrain_redraw();
run_animation_sound(10);
move_to_new_town(13,6,22);

break;